package com.globo.devsup.client.view;

import com.globo.devsup.client.presenter.Presenter;
import com.gwtext.client.core.Position;
import com.gwtext.client.widgets.Button;
import com.gwtext.client.widgets.event.ButtonListener;
import com.gwtext.client.widgets.event.WindowListener;
import com.gwtext.client.widgets.form.Checkbox;
import com.gwtext.client.widgets.form.FormPanel;
import com.gwtext.client.widgets.form.TextField;
import com.gwtext.client.widgets.layout.BorderLayout;

public class LoginView extends WindowView {

	/**
	 * ############### COMPONENTS ############### 
	 */
	private final TextField txtUserName = new TextField	("usuário", "user", 150);
	private final TextField txtPass 	= new TextField	("senha", "pass", 150);
	private final Checkbox chkGloboNet 	= new Checkbox	("Login de rede globo.com");
	private final Button btSubmit 		= new Button	("entrar");
	
	public TextField getTxtUserName() {
		return txtUserName;
	}
	public TextField getTxtPass() {
		return txtPass;
	}
	public Checkbox getChkGloboNet() {
		return chkGloboNet;
	}
	public Button getBtSubmit() {
		return btSubmit;
	}

	/**
	 * ############### SETTINGS ############### 
	 */
    public View getID(){
        return View.LOGIN_WINDOW;
    }
    
    public LoginView(Presenter presenter) {
    	super(presenter);
		
    	setLayout(new BorderLayout());
		setTitle("DevSup - login");
		setWidth(300);
		setHeight(150);
		setClosable(false);
		setResizable(false);
		
		final FormPanel formPanel = new FormPanel();
		formPanel.setFrame(true);    
		formPanel.setLabelWidth(70);
		formPanel.setLabelAlign(Position.RIGHT);
		
		txtUserName.setAllowBlank(false);
		formPanel.add(txtUserName);
		
		txtPass.setAllowBlank(false);
		txtPass.setPassword(true);
		formPanel.add(txtPass);
		
		chkGloboNet.setChecked(true);
		formPanel.add(chkGloboNet);
		  
		formPanel.addButton(btSubmit);
		
		add(formPanel);
    }
    
    
	/**
	 * ############### COMPONENTS LISTENERS ############### 
	 */
    public void setWindowActionListener(WindowListener listener){
    	addListener(listener);
    }
    
    public void setSubmitActionListener(ButtonListener listener){
    	btSubmit.addListener(listener);
    }
}
